;;; This file is part of guix-bavier.git
;;; Copyright © 2020 Eric Bavier <bavier@posteo.net>
;;; License: GPLv3+

(define-module (bavier packages irc)
  #:use-module (guix packages)
  #:use-module (guix git-download)
  #:use-module (guix build-system gnu)
  #:use-module (gnu packages bash)
  #:use-module ((guix licenses) #:prefix license:))

(define-public birch
  (let ((commit "27691aa4fb2746f73c373e6653c1fb17795729f9")
        (revision "2"))
    (package
     (name "birch")
     (version (git-version "0.0.1" revision commit))
     (home-page "https://github.com/dylanaraps/birch.git")
     (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url home-page)
                    (commit commit)))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "1272n3az6ahhqlwf17savp77956icgx6r87dylrmscm936nnqc7i"))))
     (inputs
      `(("bash-full" ,bash)))      ; Need a full-featured bash for tcp/udp handling
     (arguments
      `(#:phases (modify-phases %standard-phases
                   (delete 'configure)
                   (delete 'check)
                   (replace 'build
                     (lambda _
                       (substitute* "birch"
                         (("#kisslinux") "#guix"))
                       #t))
                   (replace 'install
                     (lambda* (#:key inputs outputs #:allow-other-keys)
                       (let ((out (assoc-ref outputs "out")))
                         (patch-shebang "birch"
                                        (list (string-append
                                               (assoc-ref inputs "bash-full")
                                               "/bin")))
                         (install-file "birch" (string-append out "/bin"))
                         (install-file "README.md"
                                       (string-append out
                                                      "/share/doc/birch-"
                                                      ,version))
                         #t)))
                   (delete 'patch-shebangs))))
     (build-system gnu-build-system)
     (synopsis "Internet Relay Chat client")
     (description "Birch is an IRC client written in GNU bash.")
     (license license:expat))))
